package Object_2;

import java.util.Arrays;

public class Student implements Comparable <Student>{
    private String name;
    private int Id;
    private double score;

    public Student(String name, int id, double score) {
        this.name = name;
        Id = id;
        this.score = score;
    }

    @Override
    public int compareTo(Student o) {
        if(this.score > o.score){
            return 1;
        }
        if(this.score < o.score){
            return -1;
        } else if(this.Id > o.Id){
            return 1;
        }else if(this.Id < o.Id){
            return -1;
        } else{
            return 0;
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", Id=" + Id +
                ", score=" + score +
                '}';
    }


    public static void main(String[] args) {
        Student s1 = new Student("张三",1,90.2);
        Student s2 = new Student("李四",2,90.5);
        System.out.println(s1.compareTo(s2));
        System.out.println(s1);
    }
}
